/**
 * 
 */
package cn.softTank.BpelModelImpl;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import cn.softTank.BpelModel.Link;

/**
 * @author Yuzone (smartzxy@gmail.com)
 * 
 */
public class LinksImpl implements cn.softTank.BpelModel.Links {

	private List<Link> link;

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.Links#addLink(cn.softTank.BpelModel.Link)
	 */
	@Override
	public void addLink(Link link) {
		if (this.link == null)
			this.link = new ArrayList<Link>();
		this.link.add(link);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.Links#getLink()
	 */
	@Override
	public List<Link> getLink() {
		return link;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.Links#removeLinkAt(int)
	 */
	@Override
	public void removeLinkAt(int index) {
		if (link != null && index < link.size())
			link.remove(index);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.Links#setLink(java.util.List)
	 */
	@Override
	public void setLink(List<Link> link) {
		this.link = link;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toElement()
	 */
	@Override
	public Element toElement() {
		Element e = DocumentHelper.createElement("links");
		if (link != null)
			for (int i = 0; i < link.size(); i++) {
				e.add(link.get(i).toElement());
			}
		return e;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toXml()
	 */
	@Override
	public String toXml() {
		// TODO Auto-generated method stub
		return null;
	}

}
